import moment from './moment.js'
// data.formatDD("yyyy-MM-DD hh:mm:ss");
Date.prototype.formatDD = function(formatStr) {
	var date = this;
	var str = formatStr;
	str = str.replace(/yyyy|YYYY/, date.getFullYear());
	str = str.replace(/yy|YY/, (date.getYear() % 100) > 9 ? (date.getYear() % 100).toString() : "0" + (date.getYear() % 100));
	str = str.replace(/MM/, date.getMonth() > 8 ? (date.getMonth() + 1).toString() : "0" + (date.getMonth() + 1));
	str = str.replace(/M/g, date.getMonth() + 1);
	str = str.replace(/dd|DD/, date.getDate() > 9 ? date.getDate().toString() : "0" + date.getDate());
	str = str.replace(/d|D/g, date.getDate());
	str = str.replace(/hh|HH/, date.getHours() > 9 ? date.getHours().toString() : "0" + date.getHours());
	str = str.replace(/h|H/g, date.getHours());
	str = str.replace(/mm/, date.getMinutes() > 9 ? date.getMinutes().toString() : "0" + date.getMinutes());
	str = str.replace(/m/g, date.getMinutes());
	str = str.replace(/ss|SS/, date.getSeconds() > 9 ? date.getSeconds().toString() : "0" + date.getSeconds());
	str = str.replace(/s|S/g, date.getSeconds());
	return str;
}

const zuiUtil = {
  devTempFlag: false, // 开发临时flag，打包时一定改成false
  isH5Page: false, // 是否h5页面 -- 五场所排查，一铺一码，重大风险专项行动
  isH5PageS: false, // 是否h5页面 -- 整个h5(isH5Page为true才生效)
  isSpecialInspection: false, // 是否是江西省2023重大风险专项行动(isH5Page为true才生效)
  isRanQi: false, // 燃气安全重大风险（isSpecialInspection为true才生效）
  regionMaxLevel: '4', // 单位信息采集最少到某一级别
	onlySmallPlace: false, // 只展示九小场所、自建房、高层建筑
	check7Day: false, // 是否每隔7天检查一次更新
	bypassLogin: false, // 是否绕过登录
	allowChangeAjaxUrl: true, // 是否允许自定义接口地址
	videoFirstIndexMock: false,
	isTianditu: false, // 逆地理编码使用天地图
	imgCommonBaseUrl: 'https://www.homepwc.com/jeecg-boot/sys/common',
  zjPlace: { // 浙江总队
    type: {
      34: '居住出租房',
      35: '生产经营性自建房',
      36: '工业企业',
      37: '高层建筑',
    }
  },
	utilName: {
		"tit": "公用utilJs中的内容zw，控制台还将会打印一些东西"
	},
	utilAlert() {
		console.log("公用util中的alert")
	},
	deepClone: function(origin, target) {
		if (target) {
			// this.zutil.deepClone(b, a); -- 把a合并到b
			// 两个对象的合并
			var target = target || {};
			for (let prop in target) {
				if (target.hasOwnProperty(prop)) {
					if (target[prop] !== null && typeof target[prop] === 'object') {
						origin[prop] = Object.prototype.toString.call(target[prop]) === '[object Array]' ? [] : {};
						this.deepClone(origin[prop], target[prop]);
					} else {
						origin[prop] = target[prop];
					}
				}
			}
		} else {
			// let c = this.zutil.deepClone(b); -- 把b复制给c
			// 对象的深拷贝
			if (typeof origin !== "object") return origin;
			let newData = origin.constructor == Array ? [] : {};
			const glob = typeof window === "undefined" ? global : window;
			if (glob.JSON) {
				/*使用JSON的方式实现拷贝*/
				newData = JSON.parse(JSON.stringify(origin));
			} else {
				/*递归实现深拷贝*/
				for (let i in origin) {
					newData[i] = typeof origin[i] == 'object' ? this.deepClone(origin[i]) : origin[i];
				}
			}
			return newData;
		}
	},
	zuiMerge: function(source, other) {
		if (!this.isObject(source) || !this.isObject(other)) {
			return other === undefined ? source : other
		}
		// 合并两个对象的 key，另外要区分数组的初始值为 []
		return Object.keys({
			...source,
			...other
		}).reduce((acc, key) => {
			// 递归合并 value
			acc[key] = this.zuiMerge(source[key], other[key])
			return acc
		}, Array.isArray(source) ? [] : {})
	},
	zuiaccAdd: function(arg1, arg2) {
		/* eslint-disable */
		var r1, r2, m;
		try {
			r1 = arg1.toString().split(".")[1].length
		} catch (e) {
			r1 = 0
		}
		try {
			r2 = arg2.toString().split(".")[1].length
		} catch (e) {
			r2 = 0
		}
		m = Math.pow(10, Math.max(r1, r2))
		return (arg1 * m + arg2 * m) / m;
		/* eslint-enable */
	},
	zuisubtr: function(arg1, arg2) {
		/* eslint-disable */
		var r1, r2, m, n;
		try {
			r1 = arg1.toString().split(".")[1].length
		} catch (e) {
			r1 = 0
		}
		try {
			r2 = arg2.toString().split(".")[1].length
		} catch (e) {
			r2 = 0
		}
		m = Math.pow(10, Math.max(r1, r2));
		n = (r1 >= r2) ? r1 : r2;
		return Number(((arg1 * m - arg2 * m) / m).toFixed(n));
		/* eslint-enable */
	},
	zuiaccMul: function(arg1, arg2) {
		/* eslint-disable */
		var m = 0,
			s1 = arg1.toString(),
			s2 = arg2.toString();
		try {
			m += s1.split(".")[1].length
		} catch (e) {}
		try {
			m += s2.split(".")[1].length
		} catch (e) {}
		return Number(s1.replace(".", "")) * Number(s2.replace(".", "")) / Math.pow(10, m);
		/* eslint-enable */
	},
	zuiaccDiv: function(arg1, arg2) {
		/* eslint-disable */
		if (arg2 == 0) return 0;
		var t1 = 0,
			t2 = 0,
			r1, r2;
		try {
			t1 = arg1.toString().split(".")[1].length
		} catch (e) {}
		try {
			t2 = arg2.toString().split(".")[1].length
		} catch (e) {}
		r1 = Number(arg1.toString().replace(".", ""));
		r2 = Number(arg2.toString().replace(".", ""));
		return (r1 / r2) * Math.pow(10, t2 - t1);
		/* eslint-enable */
	},
	removeByIndex: function(arrays, dx) {
		if (isNaN(dx) || dx > arrays.length) {
			return false;
		}
		for (var i = 0, n = 0; i < arrays.length; i++) {
			if (arrays[i] != arrays[dx]) {
				arrays[n++] = arrays[i]
			}
		}
		arrays.length -= 1
		return arrays;
	},
	removeByValue: function(arrays, item) {
		for (var i = 0; i < arrays.length; i++) {
			if (item == arrays[i]) {
				break;
			}
		}
		if (i == arrays.length) {
			return;
		}
		for (var j = i; j < arrays.length - 1; j++) {
			arrays[j] = arrays[j + 1];
		}
		arrays.length--;
		return arrays;
	},
	arrayLast: function(arrays) {
		return arrays[arrays.length - 1];
	},
	getRandomArray: function(arr, count) {
		// 从一个数组中，随机取出count个元素组成新数组
		var shuffled = arr.slice(0),
			i = arr.length,
			min = i - count,
			temp, index;
		while (i-- > min) {
			index = Math.floor((i + 1) * Math.random());
			temp = shuffled[index];
			shuffled[index] = shuffled[i];
			shuffled[i] = temp;
		}
		return shuffled.slice(min);
	},
	getCurDate(cDate, type) {
		if (cDate && !(cDate instanceof Date)) {
			cDate = new Date(cDate);
		}
		if (type && type === '2') {
			cDate = cDate.formatDD("yyyy-MM-DD hh:mm:ss");
		} else if (type) {
			cDate = cDate.formatDD("yyyy-MM-DD hh:mm");
		} else {
			cDate = cDate.formatDD("yyyy-MM-DD");
		}
		return cDate;
	},
	lStorage: {
		setParam: function(name, value) {
			localStorage.setItem(name, value);
		},
		getParam: function(name) {
			return localStorage.getItem(name);
		},
		removeParam: function(name) {
			localStorage.removeItem(name);
		},
		clearParam: function() {
			//清除所有的存储，谨慎使用
			localStorage.clear();
		}
	},
	/**
	 * 生成UUID。
	 * @param len - 长度
	 * @param radix - 基数
	 * @returns
	 */
	uuid(len, radix) {
		var chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split('');
		var uuid = [];
		var i;
		radix = radix || chars.length;

		if (len) {
			// Compact form
			for (i = 0; i < len; i++) uuid[i] = chars[0 | Math.random() * radix];
		} else {
			// rfc4122, version 4 form
			var r;
			// rfc4122 requires these characters
			uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-';
			uuid[14] = '4';
			// Fill in random data.  At i==19 set the high bits of clock sequence as
			// per rfc4122, sec. 4.1.5
			for (i = 0; i < 36; i++) {
				if (!uuid[i]) {
					r = 0 | Math.random() * 16;
					uuid[i] = chars[(i === 19) ? (r & 0x3) | 0x8 : r];
				}
			}
		}
		return uuid.join('');
	},
	createUniqueString() {
		const timestamp = +new Date() + ''
		const randomNumS = parseInt((1 + Math.random()) * 65536) + ''
		return (+(randomNumS + timestamp)).toString(32)
	},
	randomNum: function(minNum, maxNum) {
		//生成从minNum到maxNum的随机数
		switch (arguments.length) {
			case 1:
				return parseInt(Math.random() * minNum + 1, 10);
				break;
			case 2:
				return parseInt(Math.random() * (maxNum - minNum + 1) + minNum, 10);
				break;
			default:
				return 0;
				break;
		}
	},
	formatAxiosData(data) {
		return data;
		/* let _num = this.randomNum(500, 1000);
		return new Promise(function(resolve, reject) {
			setTimeout(()=>{
				resolve(data);
			}, _num)
		}) */
	},
	hasOwn(obj, key) {
		return Object.prototype.hasOwnProperty.call(obj, key);
	},
	getURLParameters: (url = window.location.href) => {
		url = url == null ? window.location.href : url
		const search = url.substring(url.lastIndexOf('?') + 1)
		const obj = {}
		const reg = /([^?&=]+)=([^?&=]*)/g
		search.replace(reg, (rs, $1, $2) => {
			const name = decodeURIComponent($1)
			let val = decodeURIComponent($2)
			val = String(val)
			obj[name] = val
			return rs
		})
		return obj
	},
	ztype: {},
	_isType: function(type) {
		if (!this.ztype[type]) {
			this.ztype[type] = function(obj) {
				return Object.prototype.toString.call(obj) === '[object ' + type + ']';
			};
		}
		return this.ztype[type];
	},
	isArray: function(obj) {
		return this._isType('Array')(obj);
	},
	isString: function(obj) {
		return this._isType('String')(obj);
	},
	isBoolean: function(obj) {
		return this._isType('Boolean')(obj);
	},
	isFunction: function(obj) {
		return this._isType('Function')(obj);
	},
	isDate: function(obj) {
		return this._isType('Date')(obj);
	},
	isNumber: function(obj) {
		return this._isType('Number')(obj);
	},
	isNumberReg: function(value) {
		if (value === undefined || value === null || value === '') {
			return false
		}
		if (typeof(value) === 'string') {
			//正整数
			var reNumber = /^\d+$/
			//负整数
			var reNeNumber = /^-\d+$/
			//正实数
			var reRealNumber1 = /^[1-9]\d*[.]\d+$/ //非零开头
			var reRealNumber2 = /^0[.]\d+$/ //零开头
			//负实数
			var reNeRealNumber1 = /^-[1-9]\d*[.]\d+$/ //非零开头
			var reNeRealNumber2 = /^-0[.]\d+$/ //零开头
			if (reNumber.test(value) || reNeNumber.test(value) ||
				reRealNumber1.test(value) || reRealNumber2.test(value) ||
				reNeRealNumber1.test(value) || reNeRealNumber2.test(value)) {
				return true
			} else {
				return false
			}
		} else if (typeof(value) === 'number') {
			return true
		} else {
			return false
		}
	},
	isNaN: function(obj) {
		return obj !== obj;
	},
	isNull: function(obj) {
		return obj === null;
	},
	isUndefined: function(obj) {
		return obj === void 0;
	},
	isNumeric: function(obj) {
		return obj - parseFloat(obj) >= 0;
	},
	isPlainObject: function(obj) {
		return obj && typeof obj === "object" && Object.getPrototypeOf(obj) === Object.prototype;
	},
	isEmpty: function(obj) {
		return this.isNull(obj) || this.isUndefined(obj) || this.isNaN(obj) || this.isString(obj) && obj === "";
	},
	isObject: function(value) {
		const type = typeof value
		return value !== null && (type === 'object' || type === 'function')
	},
	isColor: function(bgVal) {
		if (!bgVal) {
			return true;
		}
		/* eslint-disable */
		let type = '';
		if (/^rgb\(/.test(bgVal) || /^rgba\(/.test(bgVal)) {
			type =
				/^[rR][gG][Bb][Aa]?[\(]([\s]*(2[0-4][0-9]|25[0-5]|[01]?[0-9][0-9]?),){2}[\s]*(2[0-4][0-9]|25[0-5]|[01]?[0-9][0-9]?),?[\s]*(0\.\d{1,2}|1|0)?[\)]{1}$/g
		} else if (/^#/.test(bgVal)) {
			//六位或者三位
			type = "^#([0-9a-fA-F]{6}|[0-9a-fA-F]{3})$"
		} else if (/^hsl\(/.test(bgVal)) {
			//判断0-360 判断0-100%(0可以没有百分号)
			type =
				"^[hH][Ss][Ll][\(]([\\s]*(2[0-9][0-9]|360｜3[0-5][0-9]|[01]?[0-9][0-9]?)[\\s]*,)([\\s]*((100|[0-9][0-9]?)%|0)[\\s]*,)([\\s]*((100|[0-9][0-9]?)%|0)[\\s]*)[\)]$";
		} else if (/^hsla\(/.test(bgVal)) {
			type =
				"^[hH][Ss][Ll][Aa][\(]([\\s]*(2[0-9][0-9]|360｜3[0-5][0-9]|[01]?[0-9][0-9]?)[\\s]*,)([\\s]*((100|[0-9][0-9]?)%|0)[\\s]*,){2}([\\s]*(1|1.0|0|0.[0-9])[\\s]*)[\)]$";
		}
		if (!type) {
			return false;
		}
		let re = new RegExp(type);
		if (bgVal !== null) {
			if (bgVal.match(re) == null) {
				return false;
			} else {
				return true;
			}
		} else {
			return false;
		}
		/* eslint-enable */
	},
  isContain (arr1, arr2) {
    // 数组1是否是数组2的子集
    return arr1.every(item => {
      return arr2.includes(item);
    })
  },
	separator: function(num) {
		/*给数字增加千位分隔符*/
		var res = null;
		if (this.isNaN(Number(num))) {
			res = '非数字';
		} else {
			res = num.toString().replace(/\d+/, function(n) {
				return n.replace(/(\d)(?=(\d{3})+$)/g, function($1) {
					return $1 + ",";
				});
			})
		}
		return res;
	},
	trim: function(str) {
		// 去除字符串两边的空格
		if (!this.isString(str)) {
			str = String(str);
		}
		if (this.isFunction(String.prototype.trim)) {
			return String.prototype.trim.call(str);
		} else {
			return str.replace(/(^\s*)|(\s*$)/g, '');
		}
	},
	clearNoNum(obj, type) {
		// <input class="weui-input J_COD" type="text" placeholder="请输入PAM(kg)" onkeyup='clearNoNum(this)' onblur='clearNoNum(this)'>
		if (type) {
			obj.value = obj.value.replace(/[^\d.]/g, ""); //清除“数字”和“.”以外的字符  
			obj.value = obj.value.replace(/\.{2,}/g, "."); //只保留第一个. 清除多余的  
			obj.value = obj.value.replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
			if (type == '1') {
				obj.value = obj.value.replace(/^(\-)*(\d+)\.(\d).*$/, '$1$2.$3'); //只能输入一位小数
			} else if (type == '2') {
				obj.value = obj.value.replace(/^(\-)*(\d+)\.(\d{2}).*$/, '$1$2.$3'); //只能输入两个小数
			} else if (type == '3') {
				obj.value = obj.value.replace(/^(\-)*(\d+)\.(\d{3}).*$/, '$1$2.$3'); //只能输入三位小数
			}
			//以上已经过滤，此处控制的是如果没有小数点，首位不能为类似于 01、02的金额
			if (obj.value.indexOf(".") < 0 && obj.value != "") {
				obj.value = parseFloat(obj.value);
			}
			//控制.开头的数字，如：.8798321
			// \.16513000.546
			if (obj.value && !obj.value.split(".")[0]) {
				obj.value = '0.' + (obj.value.split(".")[1] || '');
				clearNoNum(obj);
			}
			if (!obj.value)
				obj.value = 0;
		} else {
			// 限制输入正整数
			obj.value = obj.value.replace(/[^\d]/g, "");
		}
	},
	// uniapp 扩展
	zconfirm(msg, callBackFun) {
		let alertTipsTit = '智慧消防';
		if(this.isRanQi) {
			alertTipsTit = '智慧燃气';
		} else if(this.isH5Page && !this.isH5PageS && !this.isSpecialInspection) {
      alertTipsTit = '智慧平台';
    }
		return new Promise((res) => {
			uni.showModal({
				title: alertTipsTit,
				content: msg,
				success: function(e) {
					if (e.confirm) {
						res(true);
					} else if (e.cancel) {
						res(false)
					}
				},
				fail: () => {
					res(false)
				}
			})
		})
	},
	zalert(msg, callBackFun) {
		let alertTipsTit = '智慧消防';
		if(this.isRanQi) {
			alertTipsTit = '智慧燃气';
		} else if(this.isH5Page && !this.isH5PageS && !this.isSpecialInspection) {
      alertTipsTit = '智慧平台';
    }
		uni.showModal({
			title: alertTipsTit,
			content: msg,
			showCancel: false,
			success: function() {
				if (!!callBackFun) {
					callBackFun()
				}
			}
		});
	},
	ztip(msg) {
		uni.showToast({
			title: msg,
			duration: 2000,
			mask: false,
			icon: "none",
		})
	},
	zuiShaker() {
		// 振动
		if (uni.getSystemInfoSync().platform == 'ios') {
			uni.vibrateShort({
				success: function() {}
			});
		} else {
			uni.vibrateLong({
				success: function() {}
			});
		}
	},
	getlistHeight(val) {
		let info = uni.getSystemInfoSync();
		console.log(info)
		return info.pixelRatio * info.windowHeight - val + 'rpx';
	},
	formatTime(time, option) {
    if(!time) {
      return;
    }
		if (('' + time).length === 10) {
			time = parseInt(time) * 1000
		}
    // ios平台下"2016-06-07 12:51:21"这种时间字符无法实现转换，ios平台只识别"2016/06/07 12:51:21"这种时间字符串格式格式
    time = (time + '').replace(/\-/g, "/");
		const d = new Date(time)
		const now = Date.now()

		const diff = (now - d) / 1000

		if (diff < 30) {
			return '刚刚'
		} else if (diff < 3600) {
			// less 1 hour
			return Math.ceil(diff / 60) + '分钟前'
		} else if (diff < 3600 * 24) {
			return Math.ceil(diff / 3600) + '小时前'
		} else if (diff < 3600 * 24 * 2) {
			return '1天前'
		}
		if (option) {
			return d.formatDD(option);
		} else {
			return (
				d.getMonth() +
				1 +
				'月' +
				d.getDate() +
				'日' +
				d.getHours() +
				'时' +
				d.getMinutes() +
				'分'
			)
		}
	},
	debounce(fn, delay) {
		// 定时器，用来 setTimeout
		var timer
		// 返回一个函数，这个函数会在一个时间区间结束后的 delay 毫秒时执行 fn 函数
		return function() {
			// 保存函数调用时的上下文和参数，传递给 fn
			const [context, args] = [this, arguments]
			// 每次这个返回的函数被调用，就清除定时器，以保证不执行 fn
			clearTimeout(timer)
			// 当返回的函数被最后一次调用后（也就是用户停止了某个连续的操作），
			// 再过 delay 毫秒就执行 fn
			timer = setTimeout(function() {
				fn.apply(context, args)
			}, delay)
		}
	},
	throttle(func, wait, mustRun) {
		var timeout,
			startTime = new Date();
		return function() {
			var context = this,
				args = arguments,
				curTime = new Date();
			clearTimeout(timeout);
			// 如果达到了规定的触发时间间隔，触发 handler
			if (curTime - startTime >= mustRun) {
				func.apply(context, args);
				startTime = curTime;
				// 没达到触发间隔，重新设定定时器
			} else {
				timeout = setTimeout(func, wait);
			}
		};
	},
	stopEvent(e) {
		if (e && e.stopPropagation) {
			e.stopPropagation();
		} else {
			window.event.cancelBubble = true;
		}
	},
	getMapPointDistance: function(lat1, lng1, lat2, lng2) {
		var radLat1 = lat1 * Math.PI / 180.0;
		var radLat2 = lat2 * Math.PI / 180.0;
		var a = radLat1 - radLat2;
		var b = lng1 * Math.PI / 180.0 - lng2 * Math.PI / 180.0;
		var s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) + Math.cos(radLat1) * Math.cos(radLat2) * Math
			.pow(Math.sin(b / 2), 2)));
		s = s * 6378.137; // 地球半径;
		s = Math.round(s * 10000) / 10000;
		// console.log("计算结果", s , 'KM');
		return s;
	},
	treeToList: function(tree) {
		var queen = [];
		var out = [];
		queen = queen.concat(tree);
		while (queen.length) {
			var first = queen.shift();
			if (first.children) {
				queen = queen.concat(first.children)
				delete first['children'];
			}
			out.push(first);
		}
		return out;
	},
	arrayToTree(a, idStr, pidStr, chindrenStr) {
		/* eslint-disable */
		var r = [],
			hash = {},
			id = idStr,
			pid = pidStr,
			children = chindrenStr,
			i = 0,
			j = 0,
			len = a.length;
		for (; i < len; i++) {
			hash[a[i][id]] = a[i];
		}
		for (; j < len; j++) {
			var aVal = a[j],
				hashVP = hash[aVal[pid]];
			if (hashVP) {
				!hashVP[children] && (hashVP[children] = []);
				hashVP[children].push(aVal);
			} else {
				r.push(aVal);
			}
		}
		return r;
		/* eslint-enable */
	},
	findParents(id, array, zkey="id") {
		// 树形结构根据id查找所有父节点
		let stack = [];
		let going = true;
		let walker = (array, id) => {
			array.forEach(item => {
				if (!going) return;
				stack.push(item);
				if (item[zkey] === id) {
					going = false;
				} else if (item['children']) {
					walker(item['children'], id);
				} else {
					stack.pop();
				}
			});
			if (going) stack.pop();
		}
		walker(array, id);
		return stack;
	},
	breadthQuery(id, tree, zkey="id") {
		// 树形结构，根据id查找当前对象
		var stark = [];
		stark = stark.concat(tree);
		while (stark.length) {
			var temp = stark.shift();
			if (temp.children) {
				stark = stark.concat(temp.children);
			}
			if (temp[zkey] === id) {
				return temp;
			}
		}
		return false;
	},
	formatZero(num, len) {
		/**
		 * 数字不够x位，前面补0
		 * @param {*} num 数字
		 * @param {*} len 补零长度
		 * @returns  0001
		 **/
		if (String(num).length > len) {
			return num;
		}
		return (Array(len).join(0) + num).slice(-len);
	},
	getDomRect(selector) {
		return new Promise(resolve => {
			uni.createSelectorQuery()['select'](selector).boundingClientRect(rect => {
				if (rect) {
					resolve(rect);
				} else {
					resolve('no info');
				}
			}).exec();
		});
	},
	formatImgs(imgList) {
		let imgs = imgList.map(x => {
			return x.id||x.attachId
		})
		return imgs.join(',')
	},
	formatImgsUrl(imgList) {
		let imgs = imgList.map(x => {
			return x.link
		})
		return imgs.join(',')
	},
	formatDate(cDate, type) {
		if (cDate && !(cDate instanceof Date)) {
			cDate = new Date(cDate);
		}
		cDate = cDate.formatDD(type);
		return cDate;
	},

	getSafeColor(type) {
		switch (type) {
			case '重大':
			case 'good':
				return '#00D3CA'
				break;
			case '较大':
			case 'well':
				return '#0090FF'
				break;
			case '一般':
			case 'pass':
				return '#FFC400'
				break;
			case '低':
			case 'danger':
				return '#FF3545'
				break;
			default:
				return '';
				break;
		}
	},
	getDay(day, formStr) {
		return moment().add(day, 'd').format(formStr)
	},
	getStartDate(day) {
		return moment(day).startOf("month").format("YYYY-MM-DD");
	},
	getEndDate(day) {
		return moment(day).endOf('month').format("YYYY-MM-DD");
	},
	getYearList() {
		var nfOptionsArray = new Array();
		var years = new Date().getFullYear();
		for (var i = years - 9; i <= years; i++) {
			nfOptionsArray.push(i);
		}
		return nfOptionsArray;
	},
	formatImgArr(imgList) {
		let imgs = imgList.map(x => {
			return x.attachId
		})
		return imgs
	},
	vforNewKeyClass () {
		let str = '';
		for (let i = 0, len = arguments.length; i < len; i++) {
			str += arguments[i] + '';
		}
		return str;
	},
	resetHighBuildType (val, emptyDefault) {
    let _val = '';
		if(!val || this.isEmpty(val) || val == 'null') {
      if(emptyDefault) {
        _val = emptyDefault;
      } else {
        _val = '';
      }
		} else {
      // _val = '1' + val;
      _val = val;
    }
    return _val;
	},
	resetHighBuildTypeS (val, emptyDefault) {
    let _val = '';
		if(!val || this.isEmpty(val) || val == 'null') {
      if(emptyDefault) {
        _val = emptyDefault;
      } else {
        _val = '';
      }
		} else {
      _val = '1' + val;
    }
    return _val;
	},
  getPlaceRuleType (flag) {
    // 场所规则类型
    if(!flag) {
      let _arr = [{"dictKey": "3", "dictValue": "九小场所"}, {"dictKey": "4", "dictValue": "自建房"}, {"dictKey": "5", "dictValue": "高层建筑"}, {"dictKey": "6", "dictValue": "老旧小区"}, {"dictKey": "7", "dictValue": "其他场所"}];
      return JSON.parse(JSON.stringify(_arr));
    } else {
      let attr = {
        3: "九小场所",
        4: "自建房",
        5: "高层建筑",
        6: "老旧小区",
        7: "其他场所",
        11: "高层公共建筑",
        12: "高层住宅建筑",
        13: "超高层",
        14: "老旧商住混合体（2000年以前）",
        15: "老旧高层建筑（2000年以后）",
      }
      let arr = [];
      for (let key in attr) {
        if (attr.hasOwnProperty(key)) {
          let _attr = {
            dictKey: key + '',
            dictValue: attr[key]
          }
          arr.push(_attr);
        }
      }
      console.log(arr);
      return arr;
    }
    return false;
  },
  getPlaceUrlByType (type) {
    let attr = {
      3: "smallPlace",
      4: "selfBuilding",
      5: "highBuilding",
      6: "oldCommunity",
      7: "otherPlace",
      11: "highBuilding",
      12: "highBuilding",
      13: "highBuilding",
      14: "highBuilding",
      15: "highBuilding",
    }
    return attr[type];
  },
  getPlaceChecklistType (type) {
    let attr = {
      // "smallPlace": "3,1,2,8,9,10",
      "smallPlace": "3",
      "selfBuilding": "4",
      "highBuilding": "5",
      "oldCommunity": "6",
      "otherPlace": "7",
    }
    return attr[type];
  },
  isVideo(item) {
    let isPass = false;
    let reg = '';
    if(this.isObject(item)) {
      reg = /.(gif|jpg|jpeg|png|gif|jpg|webp|svg)$/i.test(item.link);
    } else {
      reg = /.(gif|jpg|jpeg|png|gif|jpg|webp|svg)$/i.test(item);
    }
    if (!reg) {
      isPass = true;
    }
    return isPass;
  },
}

Number.prototype.add = function (arg) {
	return zuiUtil.zuiaccAdd(this, arg);
}
Number.prototype.sub = function (arg) {
	return zuiUtil.zuisubtr(this, arg);
}
Number.prototype.mul = function (arg) {
	return zuiUtil.zuiaccMul(this, arg);
}
Number.prototype.div = function (arg) {
	return zuiUtil.zuiaccDiv(this, arg);
}
// console.log((9).div(3).mul(2).add(2).sub(11).add(2))

export default zuiUtil;
